package com.taxi.controller;


import com.taxi.dto.Car;
import com.taxi.result.Result;
import com.taxi.service.ICarService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 *
 * @author aniu
 * @since 2023-09-28
 */
@RestController
public class CarController {
    @Autowired
    private ICarService iCarService;

    @ApiOperation("根据id获取车辆")
    @GetMapping("/get-car/{cid}")
    public Result getCarById(@PathVariable("cid") Long cid){
        return iCarService.getCar(cid);
    }

    @ApiOperation("添加或者更新车辆")
    @PostMapping("/car")
    public Result addCar(@RequestBody Car car){
        return iCarService.addCar(car);
    }

    /**
     * 查找所有车辆
     * @param page
     * @param limit
     * @return
     */
    @GetMapping("/car/list")
    public Result getCarList(@RequestParam int page, @RequestParam int limit, @RequestParam(required = false) String address, @RequestParam(required = false) String vehicleNo){
        return iCarService.getCarList(page, limit, address, vehicleNo);
    }

}
